﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAcessLayer;
using EntityModel;


namespace BusinessLayer
{
    public class BL
    {

        #region Customer

        public bool logInCustomer(Customer c)
        {
            DAL db = new DAL();
            return db.logInCustomer(c);

        }

        #endregion

        #region Private
        public Private getPrivateCustomer(string username) {
            DAL db = new DAL();
            return db.getPrivateCustomer(username);            
        }

        public List<Private> getPrivateCustomerList()
        {
            DAL db = new DAL();
            return db.getPrivateCustomerList();
        }

        public void savePrivateCustomer(Private pc) { 
            DAL db = new DAL();
             db.savePrivateCustomer(pc);
            
        }

        public void updatePrivateCustomer(Private pc)
        {
            DAL db = new DAL();
            db.updatePrivateCustomer(pc);

        }

        public void deletePrivateCustomer(Private pc)
        {
            DAL db = new DAL();
            db.deletePrivateCustomer(pc);

        }

        #endregion

        #region Business
       

        public Business getBusinessCustomer(string username)
        {
            DAL db = new DAL();
            return db.getBusinessCustomer(username);
        }

        public List<Business> getBusinessCustomerList()
        {
            DAL db = new DAL();
            return db.getBusinessCustomerList();
        }

        public void saveBusinessCustomer(Business bc)
        {
            DAL db = new DAL();
            db.saveBusinessCustomer(bc);

        }

        public void updateBusinessCustomer(Business bc)
        {
            DAL db = new DAL();
            db.updateBusinessCustomer(bc);

        }

        public void deleteBusinessCustomer(Business bc)
        {
            DAL db = new DAL();
            db.deleteBusinessCustomer(bc);

        }

        #endregion

        #region Employee
        public Employee LoginEmployee(Employee emp) { 
           DAL db = new DAL();
           if ((emp.username == "") | (emp.password == "")) { throw new Exception("Fill your username and password"); }
           else { return db.LoginEmployee(emp); }

        }
        #endregion

        #region Vehicle

        public List<Fuel> getFuelTypes() 
        {
            DAL db = new DAL();
            return db.getFuelTypes();
        }
         public List<States> getVehicleStates() 
        {
            DAL db = new DAL();
            return db.getVehicleStates();
        }
         public int getStateId(string name) {
             DAL db = new DAL();
             return db.getStateId(name);         
         }
         public int getFuelId(string name)
         {
             DAL db = new DAL();
             return db.getFuelId(name);
         }
         public string getStateName(int id)
         {
             DAL db = new DAL();
             return db.getStateName(id);

         }
         public string getFuelName(int id)
         {
             DAL db = new DAL();
             return db.getFuelName(id);

         }




        #endregion

        #region Car

         public List<TypeCar> getCarTypes() 
        {
            DAL db = new DAL();
            return db.getCarTypes();
        }

         public void saveCar(Car car) {
             DAL db = new DAL();
             db.saveCar(car);
         }

         public int getCarTypeId(string name)
         {
             DAL db = new DAL();
             return db.getCarTypeId(name);
         }

         public void deleteCar(Car car)
         {
             DAL db = new DAL();
             db.deleteCar(car);
         }

         public void updateCar(Car car)
         {
             DAL db = new DAL();
             db.updateCar(car);
         }

         public List<Car> getCarList() {
             DAL db = new DAL();
             return db.getCarList();
         }

         public Car getCar(string regnumber) {
             DAL db = new DAL();
             return db.getCar(regnumber);
         
         }

         public string getCarTypeName(int id)
         {
             DAL db = new DAL();
             return db.getCarTypeName(id);
         
         }
         public List<Car> purchasedCarsList(Private p)
         {
             DAL db = new DAL();
             return db.purchasedCarsList(p);
         }
         public List<Truck> leasedTruckList (Business b)
         {
             DAL db = new DAL();
             return db.leasedTruckList(b);
         }
         public List<Car> availableCars() {
             DAL db = new DAL();
             return db.availableCars();
         }

        #endregion

        #region Truck


         public Truck getTruck(string regnumber)
         {
             DAL db = new DAL();
             return db.getTruck(regnumber);

         }

         public void saveTruck(Truck truck)
         {
             DAL db = new DAL();
             db.saveTruck(truck);
         }


         public void deleteTruck(Truck truck)
         {
             DAL db = new DAL();
             db.deleteTruck(truck);
         }

         public void updateTruck(Truck truck)
         {
             DAL db = new DAL();
             db.updateTruck(truck);
         }

         public List<Truck> getTruckList()
         {
             DAL db = new DAL();
             return db.getTruckList();
         }

        
       

         #endregion

        #region Contracts
         public void AddLeasingContract(CLeasing c) {
             DAL db = new DAL();
             db.AddLeasingContract(c);
         }

         public List<Truck> availableTrucks()
         {
             DAL db = new DAL();
             return db.availableTrucks();
         }


         public void AddCustomerContract(CContract c)
         {
             DAL db = new DAL();
             db.AddCustomerContract(c);
         }

       
        #endregion
    }

}
